import 'package:flutter/material.dart';
import 'package:get/get.dart';

class DefaultDialogWidget extends StatelessWidget {
  final String? title;
  final bool showTitle;
  final String? content;
  final String? confirmText;
  final String? cancelText;
  final VoidCallback? onConfirm;
  final VoidCallback? onCancel;

  const DefaultDialogWidget({
    super.key,
    this.title,
    this.content,
    this.confirmText,
    this.cancelText,
    this.onConfirm,
    this.onCancel,
    this.showTitle = true,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Container(
          width: 300,
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(16),
            gradient: const LinearGradient(
              colors: [Color(0XFFF4DDC2), Colors.white],
              begin: Alignment.topCenter,
              end: Alignment(0, -.5),
            ),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              const SizedBox(height: 32),
              if (showTitle) Text(title ?? "", style: const TextStyle(fontSize: 18, color: Colors.black, fontWeight: FontWeight.w600)),
              Container(
                padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
                child: Text(
                  content ?? "",
                  textAlign: TextAlign.center,
                  style: const TextStyle(fontSize: 16, color: Color(0XFF333333), fontWeight: FontWeight.w400),
                ),
              ),
              const SizedBox(height: 16),
              SizedBox(
                height: 48,
                child: Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    const SizedBox(width: 12),
                    Expanded(
                      child: InkWell(
                        onTap: () {
                          onCancel?.call();
                          Get.back(result: false);
                        },
                        child: Container(
                          height: double.maxFinite,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(8),
                            color: const Color(0XFFEFEFEF),
                          ),
                          alignment: Alignment.center,
                          child: Text(
                            cancelText ?? "取消",
                            style: const TextStyle(fontSize: 16, color: Color(0XFF999999), fontWeight: FontWeight.w500),
                          ),
                        ),
                      ),
                    ),
                    const SizedBox(width: 12),
                    Expanded(
                      child: InkWell(
                        onTap: () {
                          onConfirm?.call();
                          Get.back(result: true);
                        },
                        child: Container(
                          height: double.maxFinite,
                          decoration: BoxDecoration(
                            gradient: const LinearGradient(colors: [Color(0XFFF4DDC2), Color(0XFFE4B591)]),
                            borderRadius: BorderRadius.circular(8),
                          ),
                          alignment: Alignment.center,
                          child: Text(
                            confirmText ?? "确定",
                            style: const TextStyle(fontSize: 16, color: Color(0XFF4A1C02), fontWeight: FontWeight.w500),
                          ),
                        ),
                      ),
                    ),
                    const SizedBox(width: 12),
                  ],
                ),
              ),
              const SizedBox(height: 16),
            ],
          ),
        ),
      ),
    );
  }
}
